<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/10/8
  Time: 13:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>菜单管理</title>
    <%@include file="../../common/header.jsp"%>
    <%@include file="../../common/ruoyi.jsp"%>
    <script>
    //显示排课信息
    function query(pageNo) {
    $.ajax({
    url:"${pageContext.request.contextPath}/menu.action?method=query&pageNo="+pageNo,
    type:"post",
    data:$("#menu-form").serialize(),
    dataType:"json",
    success:function (data) {
    $("#tb_menu").empty();
    var list=data.data;
    for (var i = 0; i < list.length; i++) {

    var parent=null;
    if (list[i].parent_id==0)
    {
    parent='根目录';
    }
    else if(list[i].parent_id==1){
    parent='系统管理';
    }
    else if(list[i].parent_id==4){
    parent='教学管理';
    }
    else {
    parent='无';
    }
    var tr="<tr>" +
    "<td>"+list[i].menu_name+"</td>" +
    "<td>"+list[i].url+"</td>" +
    "<td>"+list[i].remark+"</td>" +
    "<td>"+list[i].parent_id+"</td>" +
    "<td>"+parent+"</td>" +
    "<td>"+$("#op").html().replace('{mid}',list[i].menu_id)+"</td>" +
    "</tr>";
    $("#tb_menu").append(tr);
    }
    pager=data;
    //初始化页码信息
    var str="当前页:"+data.pageNo+"/总页数:"+data.pages;
    $("#pageinfo").html(str);
    $("#txtCurPage").val(data.curPage);
    },error:function(e){
    alert(e);
    }
    });
    }
    $(function(){
    $("#btn2").click(function(){
    //获取要跳到的页码
    var pageNo=$("#txtCurPage").val();
    if(pageNo>pager.pages) pageNo=pager.pages;
    query(pageNo);
    });
    });
    $(function () {
    query(1);
    });
    </script>
    </head>
    <body>
    <div class="col-sm-12 search-collapse">
    <form id="menu-form">
    <div class="select-list">
    <ul>
    <li>
    菜单名称：<input type="text" name="menu_name"/>
    </li>
    <li>
    通过父级菜单id查询：<input type="text" name="parent_id"/>
    </li>
    <li>
    <a class="btn btn-primary btn-rounded btn-sm" onclick="query(1)"><i class="fa fa-search"></i>&nbsp;搜索</a>
    <a class="btn btn-warning btn-rounded btn-sm" onclick=""><i class="fa fa-refresh"></i>&nbsp;重置</a>
    </li>
    </ul>
    </div>
    </form>
    </div>

    <table class="table table-bordered table-hover ">
    <caption>菜单信息</caption>
    <thead>
    <tr>
    <th>菜单名字</th>
    <th>地址</th>
    <th>备注</th>
    <th>父级id</th>
    <th>父级目录</th>

    </tr>
    </thead>
    <tbody id="tb_menu">
    </tbody>
    </table>
    <ul class="pagination">
    <li><span id="pageinfo"></span></li>
    <li><a href="javascript:void(0)" onclick="query(1)">首页</a></li>
    <li><a href="javascript:void(0)" onclick="query(pager.prev)">上页</a></li>
    <li><a href="javascript:void(0)" onclick="query(pager.next)">下页</a></li>
    <li><a href="javascript:void(0)" onclick="query(pager.last)">尾页</a></li>

   <%--绑定页数跳转id--%>
    <li class="input-group">
    <input type="number" name="curPage" max="${pager.last}" min="1" step="1" id="txtCurPage"  style="height:28px" />
    <input type="button" class="button" value="Go" id="btn2"/>
    </li>
    </li>

    </ul>


    <%--模板：html和js 分离--%>
    <script type="text/html" id="op">
    <div class="hidden-sm hidden-xs action-buttons">
    <%--<a class="view blue" href="#" onclick="" >--%>
    <%--<i class="ace-icon fa fa-search-plus "></i>查看--%>
    <%--</a>--%>
    <%--<a class="add blue" href="#" onclick="showMenus({id})" data-toggle="modal" data-target="#perModal">--%>
    <%--<i class="ace-icon fa fa-search-plus "></i>设置权限--%>
    <%--</a>--%>
    <%--<a class="green" href="#">--%>
    <%--<i class="ace-icon fa fa-pencil "></i>编辑--%>
    <%--</a>--%>
    <%--<a class="red" href="#" onclick="deleterole({roleid})"  >--%>
    <%--<i class="ace-icon fa fa-trash-o "></i>删除--%>
    <%--</a>--%>
    </div>
    </script>
</body>
</html>
